home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / local / userIcon.php < prev    next >
PHP Script  |  2010-05-19  |  4KB  |  105 lines

  1. <?php
  2. /**
  3.  * IP restriction message boxes
  4.  *
  5.  *
  6.  * PHP version 5
  7.  *
  8.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  9.  * that is available through the world-wide-web at the following URI:
  10.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  11.  * the PHP License and are unable to obtain it through the web, please
  12.  * send a note to license@php.net so we can mail you a copy immediately.
  13.  *
  14.  * @category   NA
  15.  * @package    NA
  16.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  17.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  18.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  19.  * @version    CVS: $Id:$
  20.  * @link       http://www.weezo.net
  21.  * @since      File available since Release 2.0.0
  22.  */
  23.  
  24.  
  25. if(!cfIsInApp()) die();
  26.  
  27. require_once(INCLUDE_DIR.'outputFunctions.php');
  28. require_once(INCLUDE_DIR.'explorerFunctions.php');
  29.  
  30. // Get User Id & user
  31. $userId=(isset($_GET['userId']))?$_GET['userId']:@$_POST['userId'];
  32. if(!$userId || !($user=cfArrayItem(cfMGetVar('weezoUsers'),$userId))) die('incorrect user Id');
  33. $userIcon=$user['icon'];
  34.  
  35. /*
  36.  ***************************************************************************************************************************
  37.  * Process POST commands
  38.  ***************************************************************************************************************************
  39.  */
  40.  
  41. // Add a new icon
  42. if(isset($_POST['addIcon']) && file_exists($cfn=cfUTF8Decode(str_replace('\\','/',$_POST['addIcon'])))){
  43.     $basename=cfAppDocRoot().'/gfx/icons/'.cfFileWithoutExtension(basename($cfn));
  44.     $i=0;
  45.     $ext='.jpg';
  46.     while (file_exists($basename.$ext)) {
  47.         $i++;
  48.         $ext=' ('.$i.').jpg';
  49.     }
  50.     cfCreateResizedJPG($cfn,0,0,$basename.$ext,80,80,5,false,0,true,true);
  51.     $userIcon=basename($basename.$ext);
  52. }
  53.  
  54.  
  55.  
  56.  
  57. /*
  58.  ***************************************************************************************************************************
  59.  * Display page
  60.  ***************************************************************************************************************************
  61.  */
  62. cfInsertHEAD(false);
  63. ?>
  64. <meta width="600x550"></meta>
  65. <meta title="<?php echo APPLICATION_NAME;?>"></meta>
  66. <script type="text/javascript">
  67. function browseImages(){
  68.     wl.UICommand('openFile','*.jpg;*.jpeg;*.gif;*.bmp;*.png:selectedImage')
  69. }
  70. function browseImagesProceed(cfn){
  71.     wl.postData({'addIcon':cfn,'userId':'<?php echo $userId;?>'})
  72. }
  73. function go(){
  74.     var sel= wl.blockItemGroup('userIcons').getSelectedItemsIds().toString().substr(2);
  75.     wl.UICommand('close',sel)
  76. }
  77. function cancel(){wl.UICommand('close')}
  78. </script>
  79. </head>
  80. <body style="overflow:hidden">
  81. <input name="selectedImage" onkeyup="browseImagesProceed(this.value)" style="display:none">
  82. <?php
  83. echo outDivFrame('frame1');
  84. echo outFrameHeaderTable('frame1Header',outImageIcon('chat').cfCaption('userIcon'),outButton(cfCaption('genBrowse'),'javascript:browseImages()',outIcon('blankFile')));
  85.  
  86. echo '<center><div class="frame2" style="width:590px;height:480px;overflow:scroll;margin-top:0.5em;margin-bottom:0.5em;text-align:left">';
  87.  
  88. // List icons
  89. foreach (cfGlob(cfAppDocRoot().'/gfx/icons/*.*') as $cfn) if(efFileType($cfn)=='image') $list[$cfn]=filectime($cfn);
  90. // Revert-sort by creation date
  91. arsort($list);
  92.  
  93.  
  94. // Display icons
  95. foreach ($list as $cfn=>$cdate){
  96.     echo outBlockItem('userIcons',outImage('/gfx/icons/'.basename($cfn)),'id="uI'.basename($cfn).'" ondblclick="go()"','width:100px;height:100px;padding:10px',false,((basename($cfn)==$userIcon)?'sel':'unsel'));
  97. }
  98. echo '</div>';
  99. // OK & Cancel buttons
  100. echo outBt(cfCaption('genOK'),outIcon('ok'),'javascript:go()', false,false,'style="margin-right:10em"','up',120);
  101. echo outBt(cfCaption('genCancel'),outIcon('cancel'),'javascript:cancel()',false,false,false,'up',120);
  102. ?>
  103. </center>
  104. </div>
  105. </body>